package cn.cloud.butler.scheduled.repository;

import cn.cloud.butler.scheduled.domain.CountDayEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * Created by zhouguocheng on 2018-12-28-下午 2:09
 */
public interface CountDayRepository extends JpaRepository<CountDayEntity,Integer> {

    @Query(value ="select distinct MacSN from CountDay where date(UploadTime) = DATE_SUB(curdate(),INTERVAL 1 DAY)" ,nativeQuery = true)
    List<String> selectMacsn();

    @Query(value ="select * from CountDay where MacSN = ?1 AND date(UploadTime) = DATE_SUB(curdate(),INTERVAL 1 DAY)" ,nativeQuery = true)
    List<CountDayEntity> selectMacCount(String macSn);
    @Query(value = "select * from CountDay where MacSN = ?1 and UploadTime = ?2",nativeQuery = true)
    CountDayEntity findByMac(String masn, Date time);
    @Query(value = "update CountDay set UploadTime = ?2,Count = ?3 where ID = ?1",nativeQuery = true)
    void updateCount(Integer ids, Date times,String count);

}
